package com.vy.stl.fore;

import com.github.pagehelper.PageInfo;
import com.vy.stl.constants.Constants;
import com.vy.stl.service.CourseService;
import com.vy.stl.util.Result;
import com.vy.stl.vo.CourseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @create: 2025/09/09 22:54
 * @description:Controller层--课程
 */
@RestController("foreCourseController")
@RequestMapping( "/fore")
public class CourseController {

    @Autowired
    private CourseService courseService;

    @RequestMapping("/course")
    public Result getAll(Integer page, Integer limit) {
        if (ObjectUtils.isEmpty(page) && ObjectUtils.isEmpty(limit)) {
            List<CourseVO> courseList = courseService.search(null);
            return Result.success(Constants.STATUS_200,courseList);
        }
        // 分页查询
        PageInfo pageInfo = courseService.searchByPage(page,limit,null);
        return Result.success(Constants.STATUS_200,pageInfo);
    }
}
